sdk_generate_library()
sdk_library_add_sources(croutine.c)
sdk_library_add_sources(event_groups.c)
sdk_library_add_sources(list.c)
sdk_library_add_sources(queue.c)
sdk_library_add_sources(tasks.c)
sdk_library_add_sources(timers.c)
sdk_library_add_sources(timers.c)
sdk_library_add_sources(freertos_port.c)
sdk_library_add_sources(portable/MemMang/heap_3.c)
#sdk_library_add_sources(freertos_helper/ps_extend.c)

sdk_add_include_directories(include)
#sdk_add_include_directories(freertos_helper/include)

sdk_add_compile_definitions(-DCONFIG_FREERTOS)

if(("${CHIP}" STREQUAL "bl808") AND ("${CPU_ID}" STREQUAL "d0"))
sdk_library_add_sources(portable/GCC/RISC-V/c906/port.c)
sdk_library_add_sources(portable/GCC/RISC-V/c906/portASM.S)
sdk_add_include_directories(portable/GCC/RISC-V/c906)
sdk_add_include_directories(portable/GCC/RISC-V/c906/chip_specific_extensions/Thead_E906FD_RV32IMAFDC)
sdk_add_compile_definitions(-D__OS_FREERTOS__)
else()
sdk_library_add_sources(portable/GCC/RISC-V/portStatTrap.c)
sdk_library_add_sources(portable/GCC/RISC-V/common/port.c)
sdk_library_add_sources(portable/GCC/RISC-V/common/portASM.S)
sdk_add_include_directories(portable/GCC/RISC-V/common)
sdk_add_include_directories(portable/GCC/RISC-V/common/chip_specific_extensions/RV32I_CLINT_no_extensions)
sdk_add_compile_definitions(-DportasmHANDLE_INTERRUPT=interrupt_entry -Ddefault_interrupt_handler=freertos_risc_v_trap_handler)

endif()

if(CONFIG_POSIX)
# posix for freertos
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_clock.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_mqueue.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_pthread_barrier.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_pthread_cond.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_pthread_mutex.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_pthread.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_sched.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_semaphore.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_timer.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_unistd.c)
sdk_library_add_sources(posix/source/FreeRTOS_POSIX_utils.c)
sdk_add_include_directories(posix/include)
sdk_add_include_directories(posix/include/FreeRTOS_POSIX)
sdk_add_compile_definitions(-DCONFIG_POSIX)
endif()